package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DtShoupai;
import com.ruoyi.system.service.IDtShoupaiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 党员受牌Controller
 * 
 * @author ruoyi
 * @date 2024-03-18
 */
@RestController
@RequestMapping("/system/shoupai")
public class DtShoupaiController extends BaseController
{
    @Autowired
    private IDtShoupaiService dtShoupaiService;

    /**
     * 查询党员受牌列表
     */
    @PreAuthorize("@ss.hasPermi('system:shoupai:list')")
    @GetMapping("/list")
    public TableDataInfo list(DtShoupai dtShoupai)
    {
        startPage();
        List<DtShoupai> list = dtShoupaiService.selectDtShoupaiList(dtShoupai);
        return getDataTable(list);
    }

    /**
     * 导出党员受牌列表
     */
    @PreAuthorize("@ss.hasPermi('system:shoupai:export')")
    @Log(title = "党员受牌", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DtShoupai dtShoupai)
    {
        List<DtShoupai> list = dtShoupaiService.selectDtShoupaiList(dtShoupai);
        ExcelUtil<DtShoupai> util = new ExcelUtil<DtShoupai>(DtShoupai.class);
        util.exportExcel(response, list, "党员受牌数据");
    }

    /**
     * 获取党员受牌详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:shoupai:query')")
    @GetMapping(value = "/{num}")
    public AjaxResult getInfo(@PathVariable("num") String num)
    {
        return success(dtShoupaiService.selectDtShoupaiByNum(num));
    }

    /**
     * 新增党员受牌
     */
    @PreAuthorize("@ss.hasPermi('system:shoupai:add')")
    @Log(title = "党员受牌", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DtShoupai dtShoupai)
    {
        return toAjax(dtShoupaiService.insertDtShoupai(dtShoupai));
    }

    /**
     * 修改党员受牌
     */
    @PreAuthorize("@ss.hasPermi('system:shoupai:edit')")
    @Log(title = "党员受牌", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DtShoupai dtShoupai)
    {
        return toAjax(dtShoupaiService.updateDtShoupai(dtShoupai));
    }

    /**
     * 删除党员受牌
     */
    @PreAuthorize("@ss.hasPermi('system:shoupai:remove')")
    @Log(title = "党员受牌", businessType = BusinessType.DELETE)
	@DeleteMapping("/{nums}")
    public AjaxResult remove(@PathVariable String[] nums)
    {
        return toAjax(dtShoupaiService.deleteDtShoupaiByNums(nums));
    }
}
